package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.common.persistence.model.TLogFee;
import com.stylefeng.guns.modular.system.service.ITLogFeeService;

/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2018-03-10 09:40:06
 */
@Controller
@RequestMapping("/tLogFee")
public class TLogFeeController extends BaseController {

    private String PREFIX = "/system/tLogFee/";

    @Autowired
    private ITLogFeeService tLogFeeService;

    /**
     * 跳转到首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "tLogFee.html";
    }

    /**
     * 跳转到添加
     */
    @RequestMapping("/tLogFee_add")
    public String tLogFeeAdd() {
        return PREFIX + "tLogFee_add.html";
    }

    /**
     * 跳转到修改
     */
    @RequestMapping("/tLogFee_update/{tLogFeeId}")
    public String tLogFeeUpdate(@PathVariable Integer tLogFeeId, Model model) {
        TLogFee tLogFee = tLogFeeService.selectById(tLogFeeId);
        model.addAttribute("item",tLogFee);
        LogObjectHolder.me().set(tLogFee);
        return PREFIX + "tLogFee_edit.html";
    }

    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return tLogFeeService.selectList(null);
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(TLogFee tLogFee) {
        tLogFeeService.insert(tLogFee);
        return super.SUCCESS_TIP;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer tLogFeeId) {
        tLogFeeService.deleteById(tLogFeeId);
        return SUCCESS_TIP;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TLogFee tLogFee) {
        tLogFeeService.updateById(tLogFee);
        return super.SUCCESS_TIP;
    }

    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{tLogFeeId}")
    @ResponseBody
    public Object detail(@PathVariable("tLogFeeId") Integer tLogFeeId) {
        return tLogFeeService.selectById(tLogFeeId);
    }
}
